package com.atguigu.git;

/**
 * @author JY
 */
public class BubbleSort {

    public static void bubbleSort(int[] data) {

        int len = data.length;

        for (int i = 0; i < len; i++) {
            for (int j = 0; j < len - 1 - i; j++) {
                if (data[j] > data[j + 1]) {
                    int temp = data[j];
                    data[j] = data[j + 1];
                    data[j + 1] = temp;
                }
            }
        }
    }

    public static void main(String[] args) {

        int[] data = {1, 3, 2, -4};
        System.out.println(java.util.Arrays.toString(data));

        bubbleSort(data);
        System.out.println(java.util.Arrays.toString(data));
    }

}
